export const isBlank = (value: any) => {
  return value === undefined || value === null || value === ''
}

// 数组去重
export const unique = (arr: any[]) => {
  return Array.from(new Set(arr))
}

// 首字母大小
export function titleCase(str: string) {
  return str.replace(/( |^)[a-z]/g, (L) => L.toUpperCase())
}

// 下划转驼峰
export function camelCase(str: string) {
  return str.replace(/_[a-z]/g, (str1) => str1.substr(-1).toUpperCase())
}

export function isNumberStr(str: string) {
  return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
}

export async function delay(ms: number) {
  return new Promise((resolve) => setTimeout(resolve, ms))
}

export function paddingVH(v: string, h: string) {
  return `${v} ${h}`
}
export function paddingTRBL(t: string, r: string, b: string, l: string) {
  return `${t} ${r} ${b} ${l}`
}

export function rpx(px: number) {
  return (px / 1920) * 100 + 'vw'
}
export function rpxh(px: number) {
  return (px / 1080) * 100 + 'vh'
}

export function dateFormat(date) {
  let year = date.getFullYear()
  let month = date.getMonth() + 1
  let day = date.getDate()
  return year + '-' + month + '-' + day
}

export function toggleFullScreen() {
  if (document.fullscreenElement) {
    document.exitFullscreen()
  } else {
    document.documentElement.requestFullscreen()
  }
}
